<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/2/24
 * Time: 10:12
 */

namespace app\weixin\controller;
use think\Db;


class History extends Base
{
    public function _initialize()
    {
        parent::_initialize();
    }

    public function index(){
        $activity=Db::name("activity")->select(); //获取活动列表     
        $activity_id = input('activity_id');
        $map = [];
        if(!empty($activity_id)){
            $map= ['s.aid'=>$activity_id];
        }
        $pagesize = config('paginate')['list_rows'];//每页数量
        $param=request()->param(); //获取url参数
        $lists = Db::name('season_ranking_log')
                       ->alias('s')
                       ->field('s.id,a.title,u.display_name,s.grad_name,s.count_changshu,s.count_wins,s.curr_grad_start,s.create_time')
                       ->join('activity a', 'a.id=s.`aid`')
                       ->join('user u', 'u.id=s.user_id')
                       ->where($map)
                       ->order('s.create_time')
                       ->paginate($pagesize,false,array('query' => array_splice($param,1)));
        $this->assign("lists",$lists);
        $this->assign("page", $lists->render());
        $this->assign("activity",$activity);
        $this->assign("activity_id",$activity_id);
        return $this->fetch();
    }
}